<script lang="ts">
  import { onMount } from 'svelte';
  import { Link } from 'svelte-routing';
  import { writable } from 'svelte/store';
  import { get } from '../../utils/api';
  import { addToast } from '../../stores/toastStore';
  import Header from '../../components/garage/Header.svelte';

  let loading = true; // 加载中
  let itemSendback = {
    plate_number: '鄂AFG2129', // 车牌号
    address: '回寄地址', // 回寄地址
    remark: 1, // 备注
  }
  async function getItemSendback() {
    const query = new URLSearchParams(window.location.search);
    let id = query.get('id') || '0';

    try {
      const response = await get('/operation/item-sendbacks/'+id);
      itemSendback = response.data;
    } catch (error) {
      addToast('数据加载失败'+error, 'error', 3000);
    }
  }

  onMount(() => {
    try {
      getItemSendback();
    } catch (err) {
    } finally {
      loading = false;
    }
  });
</script>

<main>
  <Header title="物品回寄详情" />
  <div class="flex flex-col px-2 py-8">
    <p><strong>发起时间：</strong>{itemSendback.created_at}</p>
    <p><strong>当前状态：</strong>{itemSendback.state}已完成</p>
    <p><strong>车牌号码：</strong>{itemSendback.plate_number}</p>
    <p><strong>备注：</strong>{itemSendback.remark}</p>
    <p><strong>回寄地址：</strong>{itemSendback.address}</p>
    <p><strong>车内物品：</strong>{itemSendback.explanation}</p>
    <p><strong>物品描述：</strong>{itemSendback.explanation}</p>
    <p><strong>回寄时间：</strong>{itemSendback.created_at}</p>
    <p><strong>物流单号：</strong>{itemSendback.tracking_number}</p>
  </div>
</main>

<style lang="scss">
</style>